﻿using System;
using Mbs.ComponentModel.Container.Metadata;

namespace Mbs.ComponentModel.Container.Listner
{
    [Serializable]
    public class DisposalListner:KernelListnerAdapter
    {
        private DisposalListner() : base(LifestyleStage.Destroyed) { }

        public static readonly IKernelListner Instance = new DisposalListner();


        public override void OnDestroyed(IComponentInfo info, object instance)
        {
            var dis = instance as IDisposable;
            if (dis != null)
                dis.Dispose();
        }
    }
}
